package scottb.cribbage.components {
import flash.events.MouseEvent;

import spark.components.Button;
import spark.components.supportClasses.SkinnableComponent;

[Bindable]
[Event(name="point", type="scottb.cribbage.components.PointStepperEvent")]
public class PointStepper extends SkinnableComponent {

    [SkinPart]
    public var addButton:Button;
    [SkinPart]
    public var minusButton:Button;
    [Bindable]
    public var enableAdd:Boolean=true;
    [Bindable]
    public var enableMinus:Boolean=true;

    public function PointStepper() {
        setStyle("skinClass", PointStepperSkin);
    }

    override protected function createChildren():void {
        super.createChildren();

        addButton.addEventListener(MouseEvent.CLICK, function(event:MouseEvent):void {
            dispatchEvent(new PointStepperEvent(1));
        });

        minusButton.addEventListener(MouseEvent.CLICK, function(event:MouseEvent):void {
            dispatchEvent(new PointStepperEvent(-1));
        });
    }
}
}
